/*    */ package com.zimbra.cs.account.ldap.entry;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.DataSource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.ldap.IAttributes.CheckBinary;
/*    */ import com.zimbra.cs.ldap.LdapException;
/*    */ import com.zimbra.cs.ldap.ZAttributes;
/*    */ import com.zimbra.soap.admin.type.DataSourceType;
/*    */ import java.util.List;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LdapDataSource
/*    */   extends DataSource
/*    */   implements LdapEntry
/*    */ {
/*    */   private String mDn;
/*    */   
/*    */   public LdapDataSource(Account acct, String dn, ZAttributes attrs, Provisioning prov)
/*    */     throws LdapException, ServiceException
/*    */   {
/* 44 */     super(acct, getObjectType(attrs), attrs.getAttrString("zimbraDataSourceName"), attrs.getAttrString("zimbraDataSourceId"), attrs.getAttrs(), prov);
/*    */     
/*    */ 
/*    */ 
/*    */ 
/* 49 */     this.mDn = dn;
/*    */   }
/*    */   
/*    */   public String getDN() {
/* 53 */     return this.mDn;
/*    */   }
/*    */   
/*    */   public static String getObjectClass(DataSourceType type) {
/* 57 */     switch (type) {
/*    */     case pop3: 
/* 59 */       return AttributeClass.OC_zimbraPop3DataSource;
/*    */     case imap: 
/* 61 */       return AttributeClass.OC_zimbraImapDataSource;
/*    */     case rss: 
/* 63 */       return AttributeClass.OC_zimbraRssDataSource;
/*    */     case gal: 
/* 65 */       return AttributeClass.OC_zimbraGalDataSource;
/*    */     }
/* 67 */     return null;
/*    */   }
/*    */   
/*    */   static DataSourceType getObjectType(ZAttributes attrs) throws ServiceException
/*    */   {
/*    */     try {
/* 73 */       String dsType = attrs.getAttrString("zimbraDataSourceType");
/* 74 */       if (dsType != null)
/* 75 */         return DataSourceType.fromString(dsType);
/*    */     } catch (LdapException e) {
/* 77 */       ZimbraLog.datasource.error("cannot get DataSource type", e);
/*    */     }
/*    */     
/* 80 */     List<String> attr = attrs.getMultiAttrStringAsList("objectClass", IAttributes.CheckBinary.NOCHECK);
/* 81 */     if (attr.contains(AttributeClass.OC_zimbraPop3DataSource))
/* 82 */       return DataSourceType.pop3;
/* 83 */     if (attr.contains(AttributeClass.OC_zimbraImapDataSource))
/* 84 */       return DataSourceType.imap;
/* 85 */     if (attr.contains(AttributeClass.OC_zimbraRssDataSource))
/* 86 */       return DataSourceType.rss;
/* 87 */     if (attr.contains(AttributeClass.OC_zimbraGalDataSource)) {
/* 88 */       return DataSourceType.gal;
/*    */     }
/* 90 */     throw ServiceException.FAILURE("unable to determine data source type from object class", null);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/entry/LdapDataSource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */